package LeetCode.month02.day52;

public class No101 {
    public boolean isSymmetric(TreeNode root) {
        if(root==null) return true;
        TreeNode left= root.left;
        TreeNode right = root.right;
        return isSym(left,right);
    }

    public boolean isSym(TreeNode left,TreeNode right){
        if(left==null&&right==null) return true;
        if(left!=null&&right!=null){
            if(left.val!=right.val) return false;
            if(!isSym(left.left,right.right)) return false;
            if(!isSym(left.right,right.left)) return false;
            return true;
        }
        return false;
    }
}
